package com.github.admin.edu.oauth.server.api.hystris;

import com.github.admin.edu.assembly.common.entity.JsonEntity;
import com.github.admin.edu.assembly.common.util.JsonUtils;
import com.github.admin.edu.oauth.server.api.service.ServerLoginServiceApi;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * Create by IntelliJ IDEA
 * 用户：王建
 * 日期：2018-7-24
 */
@Component
public class ServerLoginServiceHystris implements FallbackFactory<ServerLoginServiceApi> {

    @Override
    public ServerLoginServiceApi create(Throwable throwable) {
        return new ServerLoginServiceApi() {
            @Override
            public String getEntity(String userId) {
                return JsonUtils.toJson(new JsonEntity("无法获取用户基本信息！"));
            }

            @Override
            public String getSysUser(String id) {
                return JsonUtils.toJson(new JsonEntity<>("无法获取用户基本信息！"));
            }

            @Override
            public String getSysEntity(String userId) {
                return JsonUtils.toJson(new JsonEntity("无法获取用户基本信息！"));
            }
        };
    }
}
